<?php
include ('common/constants.php');
include ('common/db.php');
session_start();

if ((!isset($_SESSION['user_email'])) || ($_SESSION['user_email']=='')) {
  header('location: login.php');
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>User View</title>
<link href="resources/css/bootstrap.min.css" rel="stylesheet">
<link href="resources/css/bootstrap-responsive.min.css" rel="stylesheet">
<link href="resources/css/datepicker.css" rel="stylesheet">
<link href="resources/css/jquery.timepicker.css" rel="stylesheet">
<style type="text/css">
.cus_row {
	-moz-box-sizing: border-box;
	float:left;
	min-height: 1px;
	padding-right: 15px;
	position: relative;
}

.form_caja {
    padding-top: 8px;
    padding-bottom: 15px;
    margin: 0 auto 20px auto;
    background: #FFFFFF;
     border-radius: 15px;
    -moz-border-radius: 15px;
    -webkit-border-radius: 15px;
}
</style>


</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
  <div class="navbar-inner">
    <div class="container"> 
        <?php 
		
		if (!isset( $_GET )){
			echo "Nothing to view.";
		}
		
		//create array to temporarily grab variables
		$input_arr = array();
		//grabs the $_POST variables and adds slashes
		foreach ($_GET as $key => $input_arr) {
			$_GET[$key] = addslashes(htmlspecialchars($input_arr));
		}
  
		  $sql = " SELECT * FROM user where email='". $_GET['user_id']. "'";
		   
		  $result = mysql_query($sql) or trigger_error(mysql_error());
		?>
    	<a class="btn btn-navbar" style="margin-top: 25px;" data-toggle="collapse" data-target=".nav-collapse">
          <span class="icon-bar"></span> 
          <span class="icon-bar"></span> 
          <span class="icon-bar"></span> 
      	</a> <a class="brand" style="text-align:center;" href="home.php"><img src="resources/icons/share_ride.png" style="max-width:55px; padding-right:15px"/>Carpooling.lk</a>
        <div class="nav-collapse collapse">
            <ul class="nav navbar-nav">
              <li style="text-align:center; float:left">
                <a href="advertise.php"><img src="resources/icons/speaker.png" style="max-width:40px; min-width: 20px;"/><br />Advertise</a>
              </li>
              <li style="text-align:center; float:left">
                <a href="publish.php"><img src="resources/icons/publish.png" style="max-width:40px; min-width: 20px;"/><br />Publish</a>
              </li>
              <li style="text-align:center; float:left">
                <a href="#notifPanel" data-toggle="modal"><img src="resources/icons/notification.png" style="max-width:40px; min-width: 20px;"/><br />Notifications</a>
              </li>
              <li style="text-align:center; float:left">
                <a href="my_posts.php"><img src="resources/icons/my_posts.png" style="max-width:40px; min-width: 20px;"/><br />My Posts</a>
              </li>
              <li style="text-align:center; float:left">
                <a href="user_details.php"><img src="resources/icons/user_details.png" style="max-width:40px; min-width: 20px;"/><br />User Details</a>
              </li>
              <li style="text-align:center; float:left">
                <a href="preferences.php"><img src="resources/icons/preferences.png" style="max-width:40px; min-width: 20px;"/><br />Preferences</a>
              </li>
              <li style="text-align:center; float:left">
                <a data-toggle="collapse" data-target="#srch_panel"><img src="resources/icons/search.png" style="max-width:40px; min-width: 20px;"/><br />Search</a>
              </li>
              <li style="text-align:center; float:left; line-height: 0px; max-width: 200px;">
                &nbsp;&nbsp;<a class="" data-toggle="collapse"><h4>Hi <?php echo $_SESSION['user_name']?></h4></a><br />
              </li>
              <li style="text-align:center; float:left">
                &nbsp;&nbsp;<a style="padding:20px; margin: 0;" href="login.php">Sign Out</a>
          	  </li>
            </ul>
        </div>
      
        <!-- Search Panel -->
        <div id="includedSrchPanel" class="cus_row" style="width:100%"></div>
      
    </div>
  </div>
</div>
<div style="height:85px"></div>

<div class="container">


 <form class="form-actions" name="userDetails" id="userDetails">

        <fieldset>
          <legend>User View</legend>
         
          <div class="control-group">
          	<input type="hidden" name="email" id="email" value="<?php echo $_SESSION['user_email']?>" />
            
             <table class="table ng-cloak form_caja">
             <tr>
                 <td style="width: 30%;">
                     <img class="img-responsive" src="resources/icons/<?php if (mysql_result($result,0,"gender")=="M") { echo "male_user_icon.png"; } else if (mysql_result($result,0,"gender")=="F") {echo "female_user_icon.png";}?>" style="min-width: 50px;"/>
                 </td>
             </tr>
             <tr>
                 <td style="width: 30%;">
                     <small class="metadata">Full Name</small>
                 </td>
                 <td>
                     <b class="fullname"><?php echo mysql_result($result, 0, "name") ?></b>
                 </td>
             </tr>
             <tr>
                 <td>
                     <small class="metadata">E-mail</small>
                 </td>
                 <td>
                     <a class="fullname" href="mailto:<?php echo mysql_result($result, 0, "email") ?>"><?php echo mysql_result($result, 0, "email") ?></a>
                 </td>
             </tr>
             
             <tr>
                 <td>
                      <small class="metadata">Phone</small>
                 </td>
                 <td>
                      <a class="fullname" href="skype:<?php echo mysql_result($result, 0, "phone_number") ?>?call"><?php echo mysql_result($result, 0, "phone_number") ?></a>
                 </td>
             </tr>
             <tr>
                 <td>
                      <small class="metadata">Profession</small>
                 </td>
                 <td>
                      <b class="fullname"><?php echo mysql_result($result, 0, "profession") ?></b>
                 </td>
             </tr>
             <tr>
                 <td>
                      <small class="metadata">Gender</small>
                 </td>
                 <td class="fullname">
                     <b class="fullname"><?php if (mysql_result($result,0,"gender")=="M") { echo "Male"; } else if (mysql_result($result,0,"gender")=="F") {echo "Female";} ?></b>
                 </td>
             </tr>
             <tr>
                 <td>
                      <small class="metadata">User Category</small>
                 </td>
                 <td class="fullname">
                     <b class="fullname"><?php echo mysql_result($result, 0, "user_type") ?></b>
                 </td>
             </tr>
         </table>
          </div>
        </fieldset>
    </form>
    
    <!-- Notification Panel -->
    <div id="includedNotifPanel"></div>
  
  <div style="height:30px"></div>
  <!-- Site footer -->
  <div class="navbar navbar-inverse navbar-fixed-bottom">
    <div class="navbar-inner"> <a class="brand" href="#" style="padding-left:7%">&copy; Carpooling.lk 2013</a> </div>
  </div>
</div>

<!-- JAVASCRIPT INCLUDES -->
<script type="text/javascript" src="resources/js/jquery.min.js"></script>
<script type="text/javascript" src="resources/js/bootstrap-modal.js"></script>
<script type="text/javascript" src="resources/js/bootstrap-transition.js"></script>
<script type="text/javascript" src="resources/js/bootstrap-collapse.js"></script>
<script type="text/javascript" src="resources/js/bootstrap-datepicker.js"></script>
<script type="text/javascript" src="resources/js/bootstrap-typeahead.js"></script>
<script type="text/javascript" src="resources/js/jquery.timepicker.js"></script>

<script type="text/javascript">

	//Include Search panel
	$(function(){
      $("#includedSrchPanel").load("search_panel.php"); 
    });
	
	//Include Notification panel
	$(function(){
      $("#includedNotifPanel").load("notification_panel.php");
    });
	
</script>

</body>
</html>
